package com.sgb.kjwl.viewmodel.supplier3;

import com.sgb.kjwl.repository.HomeRepertory;
import com.sgb.kjwl.view.ui.activity.supplier3.SupplierActivity4;
import com.swgk.core.base.BaseViewModel;

public class SupplierModel4 extends BaseViewModel {
    private SupplierActivity4 activity4;
    private HomeRepertory repertory;
    private int page = 1;
    private int size = 20;
//    public int total;
//
//    public ObservableField<GoodsInfoTypeEntity3> typeData = new ObservableField<>(new GoodsInfoTypeEntity3());
//    public ObservableField<GoodsInfoTypeEntity3> materialData = new ObservableField<>(new GoodsInfoTypeEntity3());
//
    public SupplierModel4(SupplierActivity4 activity4, HomeRepertory repertory) {
        this.activity4 = activity4;
        this.repertory = repertory;
    }
//
////    //获取供货商列表数据
////    public void getSupplierListModel(Map map, boolean isLoadMore) {
////        page = isLoadMore ? page + 1 : 1;
////        map.put("areaCode", repertory.getAreaCode());
////        map.put("pageNum", page);
////        map.put("pageSize", size);
////        repertory.getSupplierMapData(map)
////                .subscribe(new Consumer<BaseEntity<ListResponse<List<SupplierEntity3>>>>() {
////                    @Override
////                    public void accept(BaseEntity<ListResponse<List<SupplierEntity3>>> listResponseBaseEntity) throws Exception {
////                        if (listResponseBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
////                            activity3.showList(listResponseBaseEntity.getData().getList(), isLoadMore);
////                        }
////                    }
////                }, new Consumer<Throwable>() {
////                    @Override
////                    public void accept(Throwable throwable) throws Exception {
////                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
////                    }
////                });
////    }
//
//    //获取供货商列表数据
//    public void getSupplierListModel(Map map, boolean isLoadMore) {
//        Log.e("tagmap",map.toString() );
//        page = isLoadMore ? page + 1 : 1;
//        map.put("areaCode", repertory.getAreaCode());
//        map.put("page", page);
//        map.put("limit", size);
//        repertory.getSupplierList(map)
//                .subscribe(new Consumer<BaseEntity<ListResponse<List<SupplierRecommendEntity>>>>() {
//                    @Override
//                    public void accept(BaseEntity<ListResponse<List<SupplierRecommendEntity>>> listResponseBaseEntity) throws Exception {
//                        if (listResponseBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
//                            activity4.showList(listResponseBaseEntity.getData().getList(), isLoadMore);
//                        }
//                    }
//                }, new Consumer<Throwable>() {
//                    @Override
//                    public void accept(Throwable throwable) throws Exception {
//                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
//                    }
//                });
//    }
//
//
//    public void getDistanceModel() {
//        repertory.getDistance()
//                .subscribe(new Consumer<BaseEntity<List<DictEntity3>>>() {
//                    @Override
//                    public void accept(BaseEntity<List<DictEntity3>> listBaseEntity) throws Exception {
//                        if (listBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
//                            activity4.showDistancePopWindow(listBaseEntity.getData());
//                            activity4.showTypePopWindow(listBaseEntity.getData());
//                        }
//                    }
//                }, new Consumer<Throwable>() {
//                    @Override
//                    public void accept(Throwable throwable) throws Exception {
//                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
//                    }
//                });
//    }
//
//
//    public void getSupplierCityModel() {
//        repertory.getSupplierCityData(repertory.getAreaCode())
//                .subscribe(new Consumer<BaseEntity<List<DictEntity3>>>() {
//                    @Override
//                    public void accept(BaseEntity<List<DictEntity3>> listBaseEntity) throws Exception {
//                        if (listBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
//                            activity4.showCityPopWindow(listBaseEntity.getData());
//                        }
//                    }
//                }, new Consumer<Throwable>() {
//                    @Override
//                    public void accept(Throwable throwable) throws Exception {
//                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
//                    }
//                });
//    }
//
////    public void getSupplierDistanceModel() {
////        repertory.getSupplierDistanceData()
////                .subscribe(new Consumer<BaseEntity<List<DictEntity3>>>() {
////                    @Override
////                    public void accept(BaseEntity<List<DictEntity3>> listBaseEntity) throws Exception {
////                        if (listBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
////                            activity3.showDistancePopWindow(listBaseEntity.getData());
////                            activity3.showTypePopWindow(listBaseEntity.getData());
////                        }
////                    }
////                }, new Consumer<Throwable>() {
////                    @Override
////                    public void accept(Throwable throwable) throws Exception {
////                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
////                    }
////                });
////    }
//
//    public void getSupplierSortModel() {
//        repertory.getSupplierSortData()
//                .subscribe(new Consumer<BaseEntity<List<DictEntity3>>>() {
//                    @Override
//                    public void accept(BaseEntity<List<DictEntity3>> listBaseEntity) throws Exception {
//                        if (listBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
//                            activity4.showSortPopWindow(listBaseEntity.getData());
//                        }
//                    }
//                }, new Consumer<Throwable>() {
//                    @Override
//                    public void accept(Throwable throwable) throws Exception {
//                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
//                    }
//                });
//    }
//
//    //获取供货商地图数据
//    public void getSupplierMapModel(Map map) {
//        Log.e("tag地图数据map",map.toString() );
//        map.put("current", page);
//        map.put("limit", 10);
//        repertory.getSupplierMapData(map)
//                .subscribe(new Consumer<BaseEntity<ListResponse<List<SupplierRecommendEntity>>>>() {
//                    @Override
//                    public void accept(BaseEntity<ListResponse<List<SupplierRecommendEntity>>> listResponseBaseEntity) throws Exception {
//                        if (listResponseBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
//                            activity4.showMap(listResponseBaseEntity.getData().getList());
//                        }
//                    }
//                }, new Consumer<Throwable>() {
//                    @Override
//                    public void accept(Throwable throwable) throws Exception {
//                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
//                    }
//                });
//
//    }
//
//    /**
//     * 获取经纬度
//     */
//    public void getPickupLocationModel() {
//        APIManager.getInstance().getDriverAPI().getLocationLL(repertory.getAreaCode(),null,null,null).enqueue(new Callback<BaseEntity<MapLongAndLatEntity>>() {
//            @Override
//            public void onResponse(Call<BaseEntity<MapLongAndLatEntity>> call, Response<BaseEntity<MapLongAndLatEntity>> response) {
//                if (response.body() == null) return;
//                if (response.body().getState().equals(AppConstant.REQEUST_SECCUESS)) {
//                    activity4.showLocation(response.body().getData());
//                }
//            }
//            @Override
//            public void onFailure(Call<BaseEntity<MapLongAndLatEntity>> call, Throwable t) {
//            }
//        });
//    }

//    public void getDistanceModel() {
//        repertory.getDistance()
//                .subscribe(new Consumer<BaseEntity<List<DictEntity3>>>() {
//                    @Override
//                    public void accept(BaseEntity<List<DictEntity3>> listBaseEntity) throws Exception {
//                        if (listBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
//                            activity4.showDistancePopWindow(listBaseEntity.getData());
////                            fragment.showTypePopWindow(listBaseEntity.getData());
//                        }
//                    }
//                }, new Consumer<Throwable>() {
//                    @Override
//                    public void accept(Throwable throwable) throws Exception {
//                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
//                    }
//                });
//    }

    //获取供货商列表数据
//    public void getSupplierListModel(Map map, boolean isLoadMore) {
//        Log.e("tagmap",map.toString() );
//        page = isLoadMore ? page + 1 : 1;
////        map.put("areaCode", repertory.getAreaCode());
//        map.put("page", page);
//        map.put("current", page);
//        map.put("limit", size);
//        repertory.getSupplierMapData(map)
//                .subscribe(new Consumer<BaseEntity<ListResponse<List<SupplierRecommendEntity>>>>() {
//                    @Override
//                    public void accept(BaseEntity<ListResponse<List<SupplierRecommendEntity>>> listResponseBaseEntity) throws Exception {
//                        if (listResponseBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
//                            activity4.showList(listResponseBaseEntity.getData().getList(), isLoadMore);
//                            activity4.showMap(listResponseBaseEntity.getData().getList());
//                        }
//                    }
//                }, new Consumer<Throwable>() {
//                    @Override
//                    public void accept(Throwable throwable) throws Exception {
//                        MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage());
//                    }
//                });
//    }


    //获取商品列表
//    public void getGoodsModel(HashMap<String,Object> map, boolean isLoadMore) {
//        Log.e("tagmap",map.toString() );
//        page = isLoadMore ? page + 1 : 1;
//        map.put("areaCode", repertory.getAreaCode());
//        map.put("page", page);
//        map.put("limit", size);
//        DialogHelper.showProgressDialog(activity4, null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false);
//        APIManager.getInstance().getGoodsAPI().findPromoteGoods(map).enqueue(new Callback<BaseEntity<List<PromoteGoodsEntity>>>() {
//            @Override
//            public void onResponse(Call<BaseEntity<List<PromoteGoodsEntity>>> call, Response<BaseEntity<List<PromoteGoodsEntity>>> response) {
//                DialogHelper.dismissProgressDialog();
//                if (response.body() == null)
//                    return;
//                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
//                    if (response.body().getData() == null)
//                        return;
//                    activity4.showGoodsList(response.body().getData(), isLoadMore);
//                    activity4.showGoodsMap(response.body().getData());
//                } else {
//                    MToast.showToast(activity4.getActivity(), response.message());
//                }
//            }
//
//            @Override
//            public void onFailure(Call<BaseEntity<List<PromoteGoodsEntity>>> call, Throwable t) {
//                DialogHelper.dismissProgressDialog();
//                MToast.showToast(activity4, t.getMessage());
//            }
//        });
//    }

}
